﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddRoute.aspx.cs" Inherits="msBsc.WebUi.ShpMana.AddRoute" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>添加地接客路线</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/usermenu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/from.css" rel="stylesheet" />
    <link href="/jqPlugin/hdfu/hdfu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Seller/sReleaseForum.css" rel="stylesheet" />
    <link href="/jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <link href="/jqPlugin/layer/skin/layer.css" rel="stylesheet" />
    <style type="text/css">
        .texarea {
            width: 648px;
            height: 150px;
        }

        #logo_img_selected img {
            max-height: 300px;
            /*max-width:150px;*/
        }

        .selCondition li {
            background-color: #f5f5f5;
            border: 1px solid #f5f5f5;
            float: left;
            line-height: 20px;
            margin-right: 5px;
            margin-top: 3px;
            padding: 4px 10px;
        }

        .divMaxCondition {
            display: inline;
            float: left;
            text-align: left;
            width: 720px;
        }

        .cancel {
            cursor: pointer;
            padding-left: 5px;
        }

        .additem {
            margin-left: 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="wf_all">
        <div class="main-container">
            <div class="main-Info" style="margin-bottom: 200px;">
                <div class="main-horizontal">
                    <div class="r_row">
                        <span class="control-span">标题<span class="required">*</span></span><div class="controls">
                            <input type="text" id="title" class="input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">简介<span class="required">*</span></span>
                        <div class="controls">
                            <textarea name="content" id="txtInfo" class="texarea"></textarea>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">路线特色<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="characteristic" class="input titleInput" />
                            <span id="forumInfoMessage" class="help-inline">配合标题显示在首图上，一般为一个特色景点+路线行程天数</span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">地区<span class="required">*</span></span>
                        <div class="controls">
                            <select class="selArea" id="selCountry">
                                <option value="0">请选择</option>
                                <option value="DF6723BE-A25C-4F77-BB49-A1662D3E6F2A">中国</option>
                                <option value="453370FE-8295-41EC-A41C-B6F650AD1B4C">亚洲</option>
                                <option value="927D5F28-C4FB-46A9-940C-B07DF0A04018">北美洲</option>
                                <option value="1FEAF456-7C76-41C8-A3D0-F9C12415A736">南美洲</option>
                                <option value="4E2B4524-E9CB-4E20-9224-E58EB636D1C7">非洲</option>
                                <option value="67FA6A8D-951C-4B53-AE1E-70DCB97E11DE">欧洲</option>
                                <option value="0B772F3D-D8F8-42E3-9019-81FE6F772236">大洋洲</option>
                            </select>
                            <select class="selArea" id="selCity">
                                <option value="0">请选择</option>
                            </select>
                            <xmp id="country_city_list" style="display: none">
                                <option value="0">请选择</option>
                                {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                       <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
                                {{#} }}        
                            </xmp>
                            <select class="selArea" id="selDestination">
                                <option value="0">请选择</option>
                            </select>
                            <xmp id="city_des_list" style="display: none">
                               <option value="0">请选择</option>
                               {{#for(var i=0,len=d.rows.length;i < len;i++){ }}
                                <option value="{{d.rows[i].COUNTRY_CITY_ID}}">{{d.rows[i].COUNTRY_CITY_NME}}</option>
                               {{#} }}
                            </xmp>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">涵盖景点<span class="required">*</span></span>
                        <div class="controls">
                            <textarea name="content" id="scenicSpots" class="texarea"></textarea>
                            <span class="help-inline">主要景点信息，以','间隔每个景区，15个景点以内</span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">覆盖地区<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="coverageArea" class="input titleInput" />
                            <span class="help-inline">手动输入文字，30字以内(如西南地区)</span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">路线首图<span class="required">*</span></span>
                        <div class="controls">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <div id="logo_img_selected">
                                            <img id="uHeadImg" src="/themes/Style1/Image/u_head_110x110.png" for="" />
                                        </div>
                                    </td>
                                    <td style="padding: 3px;">
                                        <div style="padding: 5px;">
                                            <a id="btnupImg" target="_self" value="上传图片" style="margin: 6px; cursor: pointer;" onclick="javascript:return false;">上传图片</a>
                                            <p>
                                                文件大小不能大于1M
                                            </p>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">路线介绍<span class="required">*</span></span>
                        <div class="controls">
                            <textarea name="content" id="routeJianjie" class="bianji"></textarea>
                            <span class="help-inline"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">路线价格<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="routePrice" value="0.00" />
                            <span class="help-inline"></span>
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">地接客<span class="required">*</span></span>
                        <div class="controls">
                            <div class="divMaxCondition">
                                <ul class="selCondition" id="djkView">
                                </ul>
                            </div>

                            <div>
                                <label>帐号:</label>
                                <input type="text" id="djkAcction" /><input type="button" onclick="selectDjk()" value="查找" />
                                <ul id="djkAccunt">
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div style="text-align: center; margin-top: 20px;">
                        <input type="button" onclick="AddRoute();" class="releaseBtn" style="margin-right: 20px;" value="发布" />
                    </div>
                </div>
            </div>
        </div>
        <!--start JS引用-->
        <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
        <script src="/jqPlugin/js/jBase.js"></script>
        <script src="/jqPlugin/js/jBPage.js"></script>
        <script src="/jqPlugin/js/laytpl.js"></script>
       <script src="/jqPlugin/layer/layer.min.js"></script>

        <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>
        <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
        <script src="/themes/wStyle1/js/comm/jsLayout.js"></script>

         <script charset="utf-8" src="/jqPlugin/kindeditor/kindeditor.js"></script>
        <script charset="utf-8" src="/jqPlugin/kindeditor/lang/zh_CN.js"></script>
        <!--end JS引用-->
        <script type="text/javascript">
            function SetAreaInfo() {
                $("#selCountry").change(function () {
                    $("#selCity").html("<option value='0'>请选择</option>");
                    $("#selDestination").html("<option value='0'>请选择</option>");
                    var _opartParam = new jsonRow();
                    _opartParam.AddCell("countryId", $("#selCountry").val());
                    _opartParam.AddCell("cityId", $("#selCity").val());
                    _opartParam.AddCell("ACTION", "changeArea");
                    ajaxComm(_opartParam);
                })

                $("#selCity").change(function () {
                    $("#selDestination").html("<option value='0'>请选择</option>");
                    var _opartParam = new jsonRow();
                    _opartParam.AddCell("cityId", $("#selCity").val());
                    _opartParam.AddCell("ACTION", "changeArea");
                    ajaxComm(_opartParam);
                })
            }
            SetAreaInfo();

            K = KindEditor;
            //        K.DEBUG = true;
            K.basePath = K.options.basePath = '/jqPlugin/kindeditor/';
            K.options.themesPath = K.options.basePath + 'themes/';
            K.options.langPath = K.options.basePath + 'lang/';
            K.options.pluginsPath = K.options.basePath + 'plugins/';
            function getfilequery() {
                return "&ParentId=" + "&FileId=" + ""
                                        + "&RelId=" + ""
                                        + "&rType1=" + "0"
                                        + "&rType2=" + "0";
            };

            var editorContend;
            function SetEditHtml(_sHtml) {
                scontenthtml = _sHtml;
            };
            var scontenthtml = '';
            $(window).load(function () {

                editorContend = K.create('#routeJianjie', {
                    allowFileManager: true,
                    resizeType: 2,
                    allowPreviewEmoticons: true,
                    allowImageUpload: true,
                    loadStyleMode: false,
                    designMode: true,
                    afterCreate: function () {
                    }
                });

                editorContend.fileManagerJson = '/pgajax.axd?F_MANA=1&rType1=0&rType2=0&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                        + "&fType=" + "mana";
                editorContend.uploadJson = '/pgajax.axd?F_UPLOAD=1&blSave=1&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                        + "&fType=" + "mana"
                                        + getfilequery();

                $.ploadFile("kindeditor", function (script, textStatus) {
                    $.setUploadFile('btnupImg', { FileId: '', RelId: "", rType1: '0', rType2: '' }, function (data) {
                        if (data.url) {
                            $('#logo_img_selected').empty().html('<img alt="" src="' + data.url + '" for="' + data.url + '">');
                        }
                    });
                });
            });

            function doBoundContent(_shopurl) {
                if (_shopurl != null && _shopurl != undefined && _shopurl != '') {
                    jQuery.loadHtml(_shopurl).done(function (_rethtml) {
                        var tpl = HtmlUtil.htmlDecode(_rethtml);
                        scontenthtml = tpl;
                        editorContend && editorContend.html(tpl);
                    });
                }
            };

            //地接客
            var djkList = new Array();
            (function () {

                //发布按钮
                $("#published").click(function () {
                    btnDo("published");
                });

            })();

            //地接客 删除
            function deleDjk(t) {
                var djkid = $(t).attr("djkid");
                $(djkList).each(function (i, e) {
                    if (e == djkid) {
                        djkList.splice(i, 1);
                        return false;
                    }
                });
                $(t).parent().remove();
            }
            //添加地接客
            function addDjk(t) {
                if (djkList.length >= 5) {
                    layer.tips('该地接客帐号最多5个', $("#djkAcction"), { guide: 0, time: 5 });
                    return;
                }

                var isAdd = false;
                var djkid = $(t).attr("djkid");

                $(djkList).each(function (i, e) {
                    if (e == djkid) { isAdd = true; return false; }
                });

                if (isAdd) {
                    layer.tips('该地接客帐号已添加过了', $("#djkAcction"), { guide: 0, time: 5 });
                    return;
                }

                var accunt = $(t).prev().html();
                var html = '<li ><span class="condition-text">' + accunt + '</span><span djkid="' + djkid + '" onclick="deleDjk(this)" class="cancel">X</span></li>';
                $("#djkView").append(html);
                djkList.push(djkid);
                $(t).parent().remove();
            }
            //查找地接客
            function selectDjk() {
                var djkAcction = $("#djkAcction").val();
                if (IsNull(djkAcction)) {
                    layer.tips('请输入地接客帐号', $("#djkAcction"), { guide: 0, time: 5 });
                    return;
                }
                var opart = new jsonRow();
                opart.AddCell("djkAcction", djkAcction);
                opart.AddCell("ACTION", "getUser");
                ajaxComm(opart);
            }
            //载入 地接客
            function loadDjkInfo(data) {
                var html = "";
                $(data.rows).each(function (i, e) {
                    html += '<li><span>' + e.CUSTOMER_NICK + '</span>';
                    html += '<span djkid="' + e.CUSTOMER_REGISTER_ID + '" onclick="addDjk(this)" class="additem">添加</span></li>';
                });
                $("#djkAccunt").html(html);
            }

            //执行AJAX调用时获取参数
            function AddRoute() {

                editorContend.sync();

                //论坛标题
                var routeTitle = $.trim($("#title").val());
                if (IsNull(routeTitle)) {
                    layer.alert('请填写标题.', 3);
                    return;
                }
                if (routeTitle.length > 30) {
                    layer.alert('标题名称不能大于30字.', 3);
                    return;
                }

                //路线特色
                var characteristic = $.trim($("#characteristic").val());
                if (IsNull(characteristic)) {
                    layer.alert('请填写路线特色.', 3);
                    return;
                }

                if (characteristic.length > 100) {
                    alert("路线特色，不能超过100个字符");
                    return;
                }
                //简介
                var txtInfo = $.trim($("#txtInfo").val());
                if (IsNull(txtInfo)) {
                    layer.alert('请填写简介.', 3);
                    return;
                }
                if (txtInfo.length > 100) {
                    alert("简介，不能超过100个字符");
                    return;
                }
                //涵盖景点
                var scenicSpots = $("#scenicSpots").val();
                if (IsNull(scenicSpots)) {
                    layer.alert('请填写涵盖景点.', 3);
                    return;
                }
                //涵盖地区
                var coverageArea = $("#coverageArea").val();
                if (IsNull(coverageArea)) {
                    layer.alert('请填写涵盖景点.', 3);
                    return;
                }
                //路线介绍
                var routeJianjie = $("#routeJianjie").val();
                if (IsNull(routeJianjie)) {
                    layer.alert('请填写路线介绍.', 3);
                    return;
                }

                var countryId = $("#selCountry").val();
                var cityId = $("#selCity").val();
                var destinationId = $("#selDestination").val();
                if (countryId == "0" || cityId == "0") {
                    layer.alert('请选择地区.', 3);
                    return;
                }
                //价格
                var price = $("#routePrice").val();
                if (IsNull(price)) {
                    layer.alert('请输入价格.', 3);
                    return;
                }
                //地接客
                var alldjk = "";
                var djkleng = alldjk.length - 1;

                $(djkList).each(function (i, e) {
                    if (i == djkleng) {
                        alldjk += e;
                    }
                    else {
                        alldjk += e + ",";
                    }
                });

                //首图
                var shoutu = $("#logo_img_selected").children().eq(0).attr("for");
                if (IsNull(shoutu)) {
                    layer.alert('请选择首图.', 2);
                    return;
                }
                layer.load('正在保存中…',2);
                var _jsParam = new jsonRow();

                _jsParam.AddCell("routeTitle", routeTitle);
                _jsParam.AddCell("coverageArea", coverageArea);
                _jsParam.AddCell("routeJianjie", routeJianjie);

                _jsParam.AddCell("scenicSpots", scenicSpots);
                _jsParam.AddCell("characteristic", characteristic);
                _jsParam.AddCell("txtInfo", txtInfo);

                _jsParam.AddCell("countryId", countryId);
                _jsParam.AddCell("cityId", cityId);
                _jsParam.AddCell("destinationId", destinationId);

                _jsParam.AddCell("routePrice", price);

                _jsParam.AddCell("djackList", alldjk);
                _jsParam.AddCell("shoutu", shoutu);
                _jsParam.AddCell("ACTION", "saveRoute");

                ajaxComm(_jsParam);
            };
            function success() {
                layer.alert('添加成功', 1);
                setTimeout(function () {
                    location.reload();
                }, 2000);
            }
        </script>
    </div>
</body>
</html>
